import {
  defineConfig,
  presetAttributify,
  presetUno,
  type Preset,
  type SourceCodeTransformer,
} from 'unocss';
import configs from './src/config/config';

import { isMp } from '@uni-helper/uni-env';
import {
  presetApplet,
  transformerApplet,
  transformerAttributify,
} from 'unocss-applet';


const presets: Preset[] = []
const transformers: SourceCodeTransformer[] = []
if (isMp) {
  // transformers.push(transformerAttributify())
  presets.push(presetApplet())
  transformers.push(transformerAttributify({ ignoreAttributes: ['block', 'fixed'] }))
  transformers.push(transformerApplet())
}
else {
  presets.push(presetAttributify({ ignoreAttributes: ['block', 'fixed'] }))
  presets.push(presetUno())
}



export default defineConfig({
  shortcuts: [
    {
      'text-main-color': `text-[${configs.colors.themeColor}]`,
      'price-color': `text-[${configs.colors.themeColor}]`,
      'bg-main-color': `bg-[${configs.colors.themeColor}]`,
      'border-main-color': `border-2rpx border-[${configs.colors.themeColor}] border-solid`,
      'bg-main-color-30': `bg-[${configs.colors.themeColor}]/30`,
      'bg-main-color-10': `bg-[${configs.colors.themeColor}]/10`,
      'bg-color': `bg-[${configs.colors.bgColor}]`,
      'text-dark-color': `text-[${configs.colors.textColor}]`,
      'link': `text-${configs.colors.themeColor}`,
      'wh-full': 'w-full h-full',
      'flex-a-c': 'flex-items-center',
      'flex-j-sb': 'flex-justify-between',
      'flex-j-c': 'flex-justify-center',
      'round': 'rounded-md',
      'card': 'bg-white rounded-20rpx ',
      'tag': `m-r-8rpx px-8rpx py-4rpx text-24rpx font-400 rounded-sm text-main-color bg-[${configs.colors.bgColor}]`,
    },
  ],
  rules: [

  ],
  presets: [
    ...presets,
  ],
  transformers: [...transformers],
})
